<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- 调用方法currentTime1，方法就需要加上括号 -->
        <p>currentTime1={{currentTime1()}}</p>
        <!-- 调用属性currentTime2，属性不需要括号-->
        <p>currentTime2={{currentTime2}}</p>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el: '#app',
            data() {
                return {
                    message: 'cpw'
                }
            },
            methods: {
                currentTime1() {
                    //返回当前时间戳
                    return Date.now();
                }
            },
            // 计算属性: 控制台输入app.message='xxx'页面将会更新
            // 计算属性主要是为了将不经常使用的的属性缓存起来，节约系统的开销
            computed: {
                currentTime2() {
                    this.message;
                    return Date.now();
                }
            }
        })
    </script>
</body>

</html>